package com.ebring.shareEducation.controller;

import com.ebring.shareEducation.bean.UserRole;
import com.ebring.shareEducation.service.UserRoleService;
import com.ebring.shareEducation.utils.RspMsg;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by Cola
 * Date  2018/8/21 09:22
 *
 * 用户角色关系模块
 */

@RestController
@CrossOrigin(origins = "http://wangliang.vipgz1.idcfengye.com", maxAge = 3600)


@Api(value = "用户角色管理" ,tags = {"用户角色管理接口"})
public class UserRoleController {

    @Autowired
    private UserRoleService userRoleService;

    // 查询用户拥有的所有角色
    @GetMapping("/userRole/select")
    @ApiOperation(value="查询用户拥有的所有角色", notes="查询用户拥有的所有角色")
    @ApiImplicitParam(paramType="query",name = "userId", value = "用户编号", required = true, dataType = "User")
    public RspMsg<List<UserRole>> select(String userId) {
        return userRoleService.select(userId);
    }

    // 修改用户角色
    @PostMapping("/userRole/update")
    @ApiOperation(value="修改用户角色", notes="修改用户角色")
    @ApiImplicitParam(paramType="query",name = "userId", value = "用户编号", required = true, dataType = "User")
    public RspMsg<UserRole> update(String userId, String[] roleId) {
        return userRoleService.update(userId, roleId);
    }


}
